// Phonetic Alphabet Generator
// Replace all alpha chars with NATO Phonetic Alphabet text.
// By Ben 23/10/2018
#include <iostream>

using namespace std;

string PhoneticText(string src){
	char pAlphabet[26][12] = { "Alfa", "Bravo", "Charlie", "Delta", "Echo",
		"Foxtrot", "Golf", "Hotel", "India", "Juliett", "Kilo", "Lima", "Mike",
		"November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango",
		"Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu" };
	
	int i = 0;
	char ch = '\0';
	string buffer = "";

	while (i < src.length()){
		//Get single char
		ch = toupper(src[i]);
		//Check for alpha only
		if (isalpha(ch)){
			//Preform a linear search of the array
			for (int n = 0; n < 26; n++){
				//Check if ch is the same as pAlphabet[n][0]
				if (ch == pAlphabet[n][0]){
					//Append to string buffer
					buffer.append(pAlphabet[n]);
					//Append a space after each word.
					buffer.append(" ");
				}
			}
		}
		//INC counter i
		i++;
	}
	return buffer;
}

int main(int argc, char **argv) {

	string s0 = "Hello World";

	string s1 = PhoneticText(s0);

	std::cout << "Input string: " << s0.c_str() << endl << endl;
	std::cout << "Phonetic Text:" << endl;
	std::cout << s1.c_str() << endl << endl;

	system("pause");
	return 0;
}